/* clock em Hz */
#define F_CPU 8000000UL

#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>


#include "src/fm.h"
#include "src/counter.h"
#include "src/wow.h"
#include "src/timers.h"
#include "src/lcd.h"
#include "src/uart.h" // debug

void main_init(void) {

  _delay_ms(50);
  timer2_init();
  fm_init();
  counter_init();
  wow_init();
  // lcd_init();
  //uart_init((F_CPU/SERIAL_BAUD/16)-1); // debug
  _delay_ms(50);
}

int main(void) {

  main_init();
  /* Enable Interrupts */
  sei();

  while(1) {
    if (T2_TASK_FLAG) {
      fm_flight_phase();
      fm_phase_task();
      T2_TASK_FLAG = 0;
      _delay_ms(2);
    }
  }

  return 0;

}
